package meisong.distribute.tomcat8080.service.impl;

import meisong.distribute.tomcat8080.bean.User;
import meisong.distribute.tomcat8080.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author 梅松
 * @Date 2021/8/23 22:35
 */
@Service
public class UserServiceImpl implements UserService {

    private List<User> users = new ArrayList<>();

    @PostConstruct
    private void init(){
        User user = new User();
        user.setUsername("meisong")
                .setPassword("123456");
        users.add(user);
    }

    @Override
    public boolean login(User user){
        for(User u:users){
            if (user.getUsername().equals(u.getUsername()) && user.getPassword().equals(u.getPassword())) {
                return true;
            }
        }
        return false;
    }
}
